'use strict';

exports.getToken = (app, data) => {
  return app.jwt.sign(
    data,
    app.config.jwt.secret,
    app.config.jwt.sign
  );
};

// 处理成功响应
exports.success = ({ ctx, data, msg = '请求成功' }) => {
  ctx.body = {
    code: 0,
    msg,
    data,
  };
  ctx.status = 200;
};

// 处理失败响应
exports.fail = ({ ctx, msg = '系统异常' }) => {
  ctx.body = {
    code: 1,
    msg,
  };
  ctx.status = 200;
};
